// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using System.Collections.Generic;

namespace SnapObjects.Data
{
    internal class SqlRawStatement : SqlStatement
    {
        public SqlRawStatement()
        {
            this.SqlRaw = new SqlClause();
            this.Parameters = new Dictionary<string, SqlParameterToken>(StringComparer.OrdinalIgnoreCase);
        }

        public SqlClause SqlRaw { get; private set; }

        public override SqlStatementType StatementType => SqlStatementType.SqlRaw;

        public override SqlTokenType Type => SqlTokenType.Statement;

        public IDictionary<string, SqlParameterToken> Parameters { get; private set; }

        public override void Clear()
        {
            this.SqlRaw.Clear();
            this.Parameters.Clear();
        }

        public override SqlStatement Clone()
        {
            return new SqlRawStatement()
            {
                SqlRaw = this.SqlRaw.Clone(),
                Parameters = new Dictionary<string, SqlParameterToken>(
                    this.Parameters, StringComparer.OrdinalIgnoreCase)
            };
        }
    }
}
